#!/bin/bash

if [ $# != 2 ]; then
	echo "$0 IP THRESHOLD"
	exit 0
fi

threshold=$2

while true; do
vdelay=`ping $1 -c 1 -W 2| grep icmp_seq | awk '{print $7}' | tr -cd "[0-9 .]" `
vdate=`date "+%Y/%m/%d-%H:%M:%S"`

if [ $vdelay ]; then
	if [ `echo "$vdelay > $threshold" | bc` -eq 1 ]; then
		echo "traffic $vdate $vdelay"
	else
		echo $vdelay
	fi
else
	echo "broken"
fi	

sleep 0.1

done

